package com.soho.mdi;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.ImageIcon;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;

public class MainFrame{

    public static void main(String[] args) {    	
    	JFrame frame = new JFrame("MDI App With Swing");
    	frame.setSize(500,500);
    	
    	MyDesktop desktop = new MyDesktop();    	
    	
    	for(int i=0;i<10;i++){
        	ImageIcon icon = new ImageIcon(MainFrame.class.getClassLoader().getSystemResource("..\\icon\\4fol.jpg"));
        	MyIcon iconPanel = new MyIcon(icon,"Test2"+i);
        	iconPanel.addMouseListener(new MouseAdapter(){
        		public void mouseClicked(MouseEvent e) {
        			if (e.getClickCount() == 2){
        				MyIcon targetIcon = (MyIcon)e.getSource();
        				System.out.println("double clicked..."+targetIcon);
        			}
        		}
        	});
        	desktop.addIcon(iconPanel);
    	}
   	
    	frame.getContentPane().add(desktop);
    	frame.setVisible(true);  	
    }
}
